package com.xiaoyu.lanling.feature.user.viewholder

import `in`.srain.cube.views.list.ViewHolderBase
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.xiaoyu.base.app.AppContext
import com.xiaoyu.lanling.R
import com.xiaoyu.lanling.feature.user.model.GiftWallItem
import com.xiaoyu.lanling.media.image.ImageLoadParam
import com.xiaoyu.lanling.media.image.ImageViewUtil

class GiftWallViewHolder : ViewHolderBase<GiftWallItem>() {

    private lateinit var mIcon: SimpleDraweeView
    private lateinit var mTitle: TextView
    private lateinit var mDesc: TextView

    override fun createView(layoutInflater: LayoutInflater, parent: ViewGroup): View? {
        val view = layoutInflater.inflate(R.layout.user_gift_wall_item, parent, false)
        mIcon = view.findViewById(R.id.icon)
        mTitle = view.findViewById(R.id.title)
        mDesc = view.findViewById(R.id.about)
        return view
    }

    override fun showData(position: Int, itemData: GiftWallItem) {
        ImageViewUtil.loadImage(mIcon, ImageLoadParam.newBuilder().setUrl(itemData.gift.icon).setSizeInDP(56).build())
        mTitle.text = itemData.gift.name
        mDesc.text = AppContext.getString(R.string.user_gift_wall_item_desc_prefix, itemData.number.toString())
    }
}